// component/nearbyStores/nearbyStores.js
var util = require('../../../utils/util')   //引入配置公共请求接口
var configUrl = require('../../../config/config')  //引入配置接口文件
const app=getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data:{
      type: Object,
      // 数据类型
      value:{}
      // 数据值
    },
    store:{
      type: Object,
      // 数据类型
      value:{}
      // 数据值
    },
    title:{
      type: String,
      // 数据类型
      value:'附近门店'
      // 数据值
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    imgUrl:getApp().globalData.imgUrl,
    shareUserId:getApp().globalData.shareUserId
  },
  onLoad: function () {
    console.log('附近门店', this.properties.store)
  },
  ready:function() {

  },
  /**
   * 组件的方法列表
   */
  methods: {
    browsePage(e) {
      let that = this
      wx.getSetting({
        success(res) {
          //这里判断是否有定位权限
          if (!res.authSetting['scope.userLocation'] || res.authSetting['scope.userLocation'] == false) {
            app.getRealLocation(resp => {
              if (resp && resp.showSetting == true) {
                let data = {showSetting: true}
                that.triggerEvent('myevent', data)
              }
            })
          } else {
            let urltype = e.currentTarget.dataset.data.linkType
            let url = e.currentTarget.dataset.data.linkUrl
            let id = e.currentTarget.dataset.data.activityPageId
            let activityUrl = '/packagBuy/pages/marketing/activityPage/activityPage' + '?id=' + id
            if (urltype == 'miniPage') {
              wx.navigateTo({
                url: url
              })
            } else if(urltype == 'h5' && url!== '/packagBuy/pages/found/crmweb/index') {
              wx.navigateTo({
                url: '/packagBuy/pages/marketing/poster/posterh5/posterh5?h5Url=' + url
              })
            } else if(url == '/packagBuy/pages/found/crmweb/index') {
              wx.navigateTo({
                url: '/packagBuy/pages/found/crmweb/index'
              })
            } else {
              wx.navigateTo({
                url: activityUrl
              })
            }
          }
        }
      })
     
    },
  }
})
